package com.whl.sm.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.whl.sm.model.approval.VApproval;
import com.whl.sm.model.notice.Attachment;
import com.whl.sm.model.system.OrgUserInfo;
import com.whl.sm.model.system.Role;
import com.whl.sm.sysEnum.CommonEnum;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Objects;


@Data
@NoArgsConstructor
/**
 * dataId 为 申请角色 id
 * */
public class ApprovalRoleVo implements Serializable {

    public ApprovalRoleVo(VApproval item, Role apRole, OrgUserInfo applicant, OrgUserInfo operator) {
        if (Objects.nonNull(item)){
            this.id = item.getId();
            this.dataType = item.getDataType();
            this.approvalStatus = item.getApprovalStatus();
            this.approvalStatusName = CommonEnum.ApprovalStatus.getValueByStep(approvalStatus);
            this.approvalRemark = item.getApprovalRemark();
            this.updateTime = item.getUpdateTime();
            this.createTime = item.getCreateTime();
        }
        if (Objects.nonNull(apRole)){
            this.roleId = apRole.getId();
            this.roleName = apRole.getRoleName();

        }
        if (Objects.nonNull(applicant)){
            this.applicant = applicant.getUserId();
            this.applicantName = applicant.getUserName();
        }
        if (Objects.nonNull(operator)){
            this.operator = operator.getUserId();
            this.operatorName = operator.getUserName();
        }
    }

    private String id;


    /**
     * 角色id
     */
    private String roleId;

    /**
     * 关联数据id role名称
     */
    private String roleName;


    /**
     * 申请数据类型
     */
    private String dataType;

    /**
     * 申请状态
     */
    private Integer approvalStatus;

    /**
     * 申请状态
     */
    private String approvalStatusName;

    /**
     * 申请备注
     */
    private String approvalRemark;

    /**
     * 申请者
     */
    private String applicant;

    /**
     * 申请者姓名
     */
    private String applicantName;

    /**
     * 操作者
     */
    private String operator;

    /**
     * 操作者姓名
     */
    private String operatorName;

    /**
     * 创建时间
     */
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createTime;

    /**
     * 更新时间
     */

    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date updateTime;




    private List<String> fileList;


    private String operateRemark;


}
